
#include <bits/stdc++.h>

const int MAXN = 100 + 5;
int n, a[MAXN];

bool check(int x) {
  // >= x 的数字是否有x个
  int cnt = 0;
  for (int i = 1; i <= n; ++i) {
    if (a[i] >= x)
      ++cnt;
  }
  return cnt >= x;
}

int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i)
    scanf("%d", a + i);
  // for(int x = 1; x <= n+1;++x){
  //     if(!check(x)){
  //         printf("%d\n",x-1);
  //         return 0;
  //     }
  // }
  int l = 0, r = n, ans = -1;
  while (l <= r) {
    int mid = (l + r) >> 1;
    if (check(mid))
      ans = mid, l = mid + 1;
    else
      r = mid - 1;
  }
  printf("%d\n", ans);
  return 0;
}